package com.ts.api.module.api.convert.receive.convert;

import com.gitee.apanlh.util.base.Eq;
import com.ts.api.module.api.convert.core.annotation.ApiReceive;
import com.ts.api.module.api.convert.core.annotation.ApiReceiveConvertType;
import com.ts.api.module.api.convert.core.context.ApiConvertRegister;
import com.ts.api.module.api.convert.receive.handler.ApiReceiveNoticeHandler;
import org.springframework.stereotype.Component;

/**
 *  API渠道推送通知转换器
 *
 *  @author Pan
 */
@Component
public class ApiReceivePushNoticeConvert extends ApiConvertRegister<ApiReceiveNoticeHandler, ApiReceive> {

    /**
     *  默认构造函数
     */
    public ApiReceivePushNoticeConvert() {
        super(
            ApiReceiveNoticeHandler.class,
            ApiReceive.class,
            (annotation) -> Eq.enums(annotation.type(), ApiReceiveConvertType.API_NOTICE_PUSH)
        );
    }

    @Override
    public String extractKey(ApiReceive annotation) {
        return annotation.apiClientId();
    }

    @Override
    public ApiReceiveNoticeHandler getDefaultHandler() {
        return getHandler(ApiReceiveConvertType.API_NOTICE_PUSH.getDefaultBeanName());
    }
}

